package org.tedu.cloudnote.serviceImpl;
import java.sql.Timestamp;
import java.util.List;

import javax.annotation.Resource;

import org.springframework.stereotype.Service;
import org.tedu.cloudnote.dao.BookDao;
import org.tedu.cloudnote.entity.Book;
import org.tedu.cloudnote.service.BookService;
import org.tedu.cloudnote.util.NoteResult;
import org.tedu.cloudnote.util.NoteUtil;

@Service("bookService")
public class BookServiceImpl implements BookService{
	@Resource
private BookDao dao;
	public NoteResult loadNoteBooks(String userId) {
		NoteResult result=new NoteResult();
		List<Book> books=dao.loadBooks(userId);
		result.setStatus(0);
		result.setMsg("加载成功");
		result.setData(books);
		return result;
	}
	public NoteResult addBooks(String notebookname, String userId) {
		NoteResult result=new NoteResult();
		Book books=new Book();
		Timestamp time=new Timestamp(System.currentTimeMillis());
		books.setCn_notebook_createtime(time);
		String bookId=NoteUtil.createId();
		books.setCn_notebook_id(bookId);
		books.setCn_notebook_name(notebookname);
		books.setCn_user_id(userId);
		books.setCn_notebook_type_id("5");
		books.setCn_notebook_desc("");
	   dao.addBook(books);
		result.setStatus(0);
		result.setMsg("创建成功");
		result.setData(bookId);
		return result;
	}


}
